package base_server

import (
	"fmt"
	"google.golang.org/grpc"
	common "jihe.common"
	"jihe.common/protos/base_server/proto"
	"net"
)

var conf = new(common.Config)

func GrpcServer(srv proto.BaseServer) {
	lis, err := net.Listen("tcp", fmt.Sprintf(":%d", conf.Get().Grpc.Port))
	if err != nil {
		panic(err)
	}
	var opts []grpc.ServerOption
	svr := grpc.NewServer(opts...)
	proto.RegisterBaseServer(svr, srv)
	err = svr.Serve(lis)
	if err != nil {
		panic(err)
	}
}
